Skip to content

fix(agent): reject unsafe mandate numeric fields - #284

Merged
karagozemin merged 2 commits into
Sub-Rosa-Issue:mainfrom
emrekayat:fix/273-unsafe-numeric-mandate
Aug 31, 2026
Merged

fix(agent): reject unsafe mandate numeric fields#284
karagozemin merged 2 commits into
Sub-Rosa-Issue:mainfrom
emrekayat:fix/273-unsafe-numeric-mandate

Conversation

@emrekayat

Copy link
Copy Markdown
Contributor

Fixes #273.

Validates mandate timestamps, prices, round IDs, and stroop strings at creation and verification boundaries with stable MandateError messages. Adds boundary and malformed-value tests.

Copilot AI lite review requested due to automatic review settings August 31, 2026 01:22
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@emrekayat Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements stricter numeric validation for session mandate payloads at both creation and verification boundaries, aiming to reject unsafe numeric inputs (NaN/Infinity/fractional/unsafe-integer) with stable MandateError messages, and adds regression tests for malformed values.

Changes:

  • Added centralized numeric field validation (validateMandateNumbers) to enforce safe integers for timestamps/prices and integer-only strings for round IDs and stroop fields.
  • Applied the new validation in both createSessionMandate and verifySessionMandate for consistent, stable error behavior.
  • Added tests covering unsafe/malformed mandate fields and signature-preserving malformed payload scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
services/agent/src/mandate.ts Introduces numeric validation helpers and enforces them during mandate creation and verification.
services/agent/src/mandate.test.ts Adds tests to ensure unsafe/malformed mandate fields are rejected with stable MandateError messages.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

issuedAt: now,
expiresAt: now + (params.ttlSeconds ?? 3600),
};
validateMandateNumbers(payload);
Comment on lines +106 to +110
assert.throws(
() => createSessionMandate({ ...p, roundId: 1.5 }),
(error: unknown) => error instanceof MandateError && error.message === "invalid mandate roundId",
);
});
@karagozemin
karagozemin merged commit 4e0954f into Sub-Rosa-Issue:main Aug 31, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject unsafe numeric mandate fields

3 participants